Remove GTK_ACCESSIBLE_STATE_NONE
authorEmmanuele Bassi <ebassi@gnome.org>
Wed, 15 Jul 2020 12:20:38 +0000 (13:20 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Sun, 26 Jul 2020 19:31:15 +0000 (20:31 +0100)
It's pointless, we can use an explicit value of `-1` everywhere.
Additionally, it complicates all code that uses the state enumeration as
an array index, since now we need to guard against a negative offset.

gtk/gtkaccessible.c
gtk/gtkaccessiblevalue.c
gtk/gtkenums.h

index c06612ba837cbf48faf4c32fb14c0c1161423573..8cace466114b8d2a211be0995bab70988c38d278 100644 (file)
@@ -108,7 +108,7 @@ gtk_accessible_get_accessible_role (GtkAccessible *self)
  * gtk_accessible_update_state:
  * @self: a #GtkAccessible
  * @first_state: the first #GtkAccessibleState
- * @...: a list of state and value pairs, terminated by %GTK_ACCESSIBLE_STATE_NONE
+ * @...: a list of state and value pairs, terminated by -1
  *
  * Updates a list of accessible states.
  *
@@ -134,7 +134,7 @@ gtk_accessible_update_state (GtkAccessible      *self,
 
   state = first_state;
 
-  while (state != GTK_ACCESSIBLE_STATE_NONE)
+  while (state != -1)
     {
       GtkAccessibleValue *value = gtk_accessible_value_collect_for_state (state, &args);
 
index 6509272205f78db2cb54b707312363a0b35c6994..db2509ebd6dce01c12fb5138b604d7fbe35d6aec 100644 (file)
@@ -538,8 +538,6 @@ typedef GtkAccessibleValue * (* GtkAccessibleValueRefCtor)      (gpointer value)
 GtkAccessibleValue *
 gtk_accessible_value_get_default_for_state (GtkAccessibleState state)
 {
-  g_assert (state != GTK_ACCESSIBLE_STATE_NONE);
-
   const GtkAccessibleCollect *cstate = &collect_states[state];
 
   switch (cstate->value)
@@ -589,8 +587,6 @@ GtkAccessibleValue *
 gtk_accessible_value_collect_for_state (GtkAccessibleState  state,
                                         va_list            *args)
 {
-  g_assert (state != GTK_ACCESSIBLE_STATE_NONE);
-
   const GtkAccessibleCollect *cstate = &collect_states[state];
 
   GtkAccessibleValue *res = NULL;
@@ -697,8 +693,6 @@ GtkAccessibleValue *
 gtk_accessible_value_collect_for_state_value (GtkAccessibleState  state,
                                               const GValue       *value)
 {
-  g_assert (state != GTK_ACCESSIBLE_STATE_NONE);
-
   const GtkAccessibleCollect *cstate = &collect_states[state];
 
   GtkAccessibleValue *res = NULL;
index d7080d47c7bb9ca13512aea0534ce1a9b6f05c54..30bfc568c57ef4bc5937b79a099a3b6eb58475e3 100644 (file)
@@ -1302,30 +1302,31 @@ typedef enum {
 
 /**
  * GtkAccessibleState:
- * @GTK_ACCESSIBLE_STATE_NONE: An invalid state, used as a sentinel value
  * @GTK_ACCESSIBLE_STATE_BUSY: A “busy” state
- * @GTK_ACCESSIBLE_STATE_CHECKED: A “checked” state; corresponds to the
- *   #GtkToggleButton:active property on #GtkToggleButton
+ * @GTK_ACCESSIBLE_STATE_CHECKED: A “checked” state; indicates the current
+ *   state of a #GtkCheckButton
  * @GTK_ACCESSIBLE_STATE_DISABLED: A “disabled” state; corresponds to the
- *   #GtkWidget:sensitive property on #GtkWidget
+ *   #GtkWidget:sensitive property on #GtkWidget. It indicates a UI element
+ *   that is perceivable, but not editable or operable
  * @GTK_ACCESSIBLE_STATE_EXPANDED: An “expanded” state; corresponds to the
  *   #GtkExpander:expanded property on #GtkExpander
  * @GTK_ACCESSIBLE_STATE_GRABBED: A “grabbed” state; set when a widget is
  *   being grabbed in a drag and drop operation
  * @GTK_ACCESSIBLE_STATE_HIDDEN: A “hidden” state; corresponds to the
- *   #GtkWidget:visible property on #GtkWidget
+ *   #GtkWidget:visible property on #GtkWidget. You can use this state
+ *   explicitly on UI elements that should not be exposed to an assistive
+ *   technology. See also: %GTK_ACCESSIBLE_STATE_DISABLED
  * @GTK_ACCESSIBLE_STATE_INVALID: An “invalid” state; set when a widget
  *   is showing an error
- * @GTK_ACCESSIBLE_STATE_PRESSED: A “pressed” state; set when a widget
- *   is being activated by a pointer
+ * @GTK_ACCESSIBLE_STATE_PRESSED: A “pressed” state; indicates the current
+ *   state of a #GtkToggleButton
  * @GTK_ACCESSIBLE_STATE_SELECTED: A “selected” state; set when a widget
  *   is selected
  *
  * The possible accessible state of a #GtkAccessible.
  */
 typedef enum {
-  GTK_ACCESSIBLE_STATE_NONE = -1,
-  GTK_ACCESSIBLE_STATE_BUSY = 0,
+  GTK_ACCESSIBLE_STATE_BUSY,
   GTK_ACCESSIBLE_STATE_CHECKED,
   GTK_ACCESSIBLE_STATE_DISABLED,
   GTK_ACCESSIBLE_STATE_EXPANDED,